/***
 * chuck
 * 20170221 签订前要点审批列表2
 */
(function () {
    var serverData = {};
    var serverTable;
    //打印方法
    jQuery('#printBtn').on('click',function(){
    	var selects=getSelect("#dataTable",1);
    	if(selects.length>1){
		   $.springLemonDialog({
		         content: '只能打印一条记录',// 确认文本
		         clickButton: function (sender, modal, index) {// 按钮事件处理
		             $(this).closeDialog(modal);
		         }
		   }); 
	   }else if(selects.length==0){
		   $.springLemonDialog({
		         content: '请选择要打印的记录',// 确认文本
		         clickButton: function (sender, modal, index) {// 按钮事件处理
		             $(this).closeDialog(modal);
		         }
		   }); 
	   }else{
		   url = window.rootPath + '/ui/beforecontract/getPrintPage?id='+selects[0].id;
	    	jQuery.ajax({
	    		url : encodeURI(url),
	    		type : 'get',
	    		dataType : 'json',
	    		contentType : 'application/json;charset=utf-8',
	    		success : function(data) {
	    			var printTable = "<div style='margin-top:60px'><span style='margin-left:39%;font-size:17px;'><strong>市场部合同签订前要点审批</strong><span></div>";
	    	        printTable+= "<div><span style='margin-left:80%;font-size:10px;'>质量记录编号：CB.Q-66</span></div>";
	    	        printTable+= "<table border='1' style='border-top-style: solid;border-right-style: solid;border-bottom-style: solid;border-left-style: solid;"
	    	        printTable+= " border-top-color: black ;border-right-color: black ;border-bottom-color: black ;border-left-color: black ;"
	    	        printTable+="text-align:center;font-size:13px;border-collapse:collapse;border-spacing:0; margin-left:40px;' width='91%' >";
	    	        	//1
	    	        	printTable += "<tr>";
	    	        		printTable += "<td>";
	    	        			printTable += "合同号"
	    	        		printTable += "</td>";
	    	        		printTable += "<td>"+data.beforeContract.cContractCode;
	    	        		printTable += "</td>";
	    	        		printTable += "<td colspan='2'>";
	    	        			printTable += "用户单位"
	    	        		printTable += "</td>";
	    	    			printTable += "<td colspan='4'>"+data.beforeContract.cOrderUnitName;
	    	        		printTable += "</td>";
	    	        		printTable += "<td colspan='3'>";
	    	        			printTable += "合同责任人"
	    	        		printTable += "</td>";
	    	    			printTable += "<td>"+data.beforeContract.cDutyPersonName;
	    	        		printTable += "</td>";
	    	        	printTable += "</tr>";
	    	        	//2
	    	        	printTable += "<tr>";
	    	        		printTable += "<td>";
	    	        			printTable += "合同总价(元)"
	    	        		printTable += "</td>";
	    	        		printTable += "<td>"+data.beforeContract.nContractPrice;
	    	        		printTable += "</td>";
	    	        		printTable += "<td colspan='2'>";
	    	        			printTable += "项目名称"
	    	        		printTable += "</td>";
	    	    			printTable += "<td colspan='4'>"+data.beforeContract.cProjectName;
	    	        		printTable += "</td>";
	    	        		printTable += "<td colspan='3'>";
	    	        			printTable += "预计签订时间"
	    	        		printTable += "</td>";
	    	    			printTable += "<td>"+new Date(data.beforeContract.dPlanSignDate).toLocaleDateString();
	    	        		printTable += "</td>";
	    	        	printTable += "</tr>";
	    	        	printTable += "<tr height='40px'>";
	    	        		printTable +="<td>";
		    	        	printTable +="</td>";
		    	        	printTable +="<td colspan='5'>产品名称、型号或技术要求";
			    	        printTable +="</td>";
				    	    printTable +="<td>数量";
					    	printTable +="</td>";
					    	printTable +="<td colspan='2'>合同价（万元）";
					    	printTable +="</td>";
					    	printTable +="<td colspan='2'>出厂价（万元）";
					    	printTable +="</td>";
					    	printTable +="<td>加减价（万元）"
					    	printTable +="</td>";
	    	        	printTable += "</tr>";
	    	        	var count = data.htbdw.length+4;
	    	        	for(var i = 0;i<data.htbdw.length;i++){//计算合同标的物跨列
	    	        		count += data.htbdw[i].patr.length
	    	        	}
	    	        	printTable += "<tr>";
	    	        	printTable += "<td rowspan='"+count+"'>合同标的物情况"
	    	        	printTable += "</td>"
	    	        	for(var k = 0;k<data.htbdw.length;k++){
	    	        		printTable += "<td>泵名称";
	    	        		printTable += "</td>";
	    	        		printTable += "<td>"+data.htbdw[k].cProductName;
	    	        		printTable += "</td>";
	    	        		printTable += "<td>型号";
	    	        		printTable += "</td>";
	    	        		printTable += "<td colspan='2'>"+data.htbdw[k].cProductType;
	    	        		printTable += "</td>";
	    	        		printTable += "<td>"+data.htbdw[k].nCount;
	    	        		printTable += "</td>";
	    	        		printTable += "<td colspan='2'>"+data.htbdw[k].nContractPrice;
	    	        		printTable += "</td>";
	    	        		printTable += "<td colspan='2'>"+data.htbdw[k].nOutPrice;
	    	        		printTable += "</td>";
	    	        		printTable += "<td>"+data.htbdw[k].nAddOrReducePrice;
	    	        		printTable += "</td>";
	    	        		printTable+="</tr>";
	    	        		for(var z=0;z<data.htbdw[k].patr.length;z++){
	    	        			printTable += "<tr>";
	    	        				printTable += "<td colspan='5'>"+data.htbdw[k].patr[z].cName;
	    	        				printTable += "</td>";
	    	        				printTable += "<td>"+data.htbdw[k].patr[z].nCount;
	    	        				printTable += "</td>";
	    	        				printTable += "<td colspan='2'>"+data.htbdw[k].patr[z].nContractPrice;
	    	    	        		printTable += "</td>";
	    	    	        		printTable += "<td colspan='2'>"+data.htbdw[k].patr[z].nOutPrice;
	    	    	        		printTable += "</td>";
	    	    	        		printTable += "<td>"+data.htbdw[k].patr[z].nAddOrReducePrice;
	    	    	        		printTable += "</td>";
	    	        			printTable += "</tr>";
	    	        		}
	    	        	}
	    	        	printTable += "<tr>";
	    	        		printTable += "<td colspan='5'>运保费";
	    	        		printTable += "</td>";
	    	        		printTable += "<td>";
	    	        		printTable += "</td>";
	    	        		printTable += "<td colspan='2'>"+data.beforeContract.nDeliveryPrice;
	    	        		printTable += "</td>";
	    	        		printTable += "<td colspan='2'>0.00";
	    	        		printTable += "</td>";
	    	        		printTable += "<td>0.00";
	    	        		printTable += "</td>";
	    	        	printTable += "</tr>";
	    	        	printTable += "<tr>";
	    	        		printTable += "<td colspan='5'>服务费";
	    	        		printTable += "</td>";
	    	        		printTable += "<td>";
	    	        		printTable += "</td>";
	    	        		printTable += "<td colspan='2'>"+data.beforeContract.nServicePrice;
	    	        		printTable += "</td>";
	    	        		printTable += "<td colspan='2'>0.00";
	    	        		printTable += "</td>";
	    	        		printTable += "<td>0.00";
	    	        		printTable += "</td>";
	    	        	printTable += "</tr>";
	    	        	printTable += "<tr>";
	    	        		printTable += "<td colspan='5'>合计";
	    	        		printTable += "</td>";
	    	        		printTable += "<td>";
	    	        		printTable += "</td>";
	    	        		printTable += "<td colspan='2'>"+data.beforeContract.nTotalContractPrice;
	    	        		printTable += "</td>";
	    	        		printTable += "<td colspan='2'>0.00";
	    	        		printTable += "</td>";
	    	        		printTable += "<td>0.00";
	    	        		printTable += "</td>";
	    	        	printTable += "</tr>";
	    	        	printTable += "<tr>";
	    	        		printTable += "<td colspan='5'>加减比例（%）";
	    	        		printTable += "</td>";
	    	        		if(data.beforeContract.nDisCountPercent <= 0){
	    	        			var a = 0-data.beforeContract.nDisCountPercent;
	    	        			printTable += "<td>加价";
		    	        		printTable += "</td>";
		    	        		printTable += "<td colspan='2'>0.00";
		    	        		printTable += "</td>";
		    	        		printTable += "<td colspan='2'>减价";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>"+a;
		    	        		printTable += "</td>";
	    	        		}else{
	    	        			var a = 0-data.beforeContract.nDisCountPercent;
	    	        			printTable += "<td>加价";
		    	        		printTable += "</td>";
		    	        		printTable += "<td colspan='2'>"+a;
		    	        		printTable += "</td>";
		    	        		printTable += "<td colspan='2'>减价";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>0.00";
		    	        		printTable += "</td>";
	    	        		}
	    	        	printTable += "</tr>";
	    	        	printTable += "<tr>";
		    	        	printTable += "<td>交货期";
	    	        		printTable += "</td>";
	    	        		printTable += "<td colspan='11'>"+data.beforeContract.cDeliveryMemo;
	    	        		printTable += "</td>";
	    	        	printTable += "</tr>";
	    	        	printTable += "<tr>";
		    	        	printTable += "<td>质保期";
	    	        		printTable += "</td>";
	    	        		printTable += "<td colspan='11'>"+data.beforeContract.cQualityMemo;
	    	        		printTable += "</td>";
	    	        	printTable += "</tr>";
	    	        	printTable += "<tr>";
		    	        	printTable += "<td>付款方式";
	    	        		printTable += "</td>";
	    	        		printTable += "<td colspan='11'>"+data.beforeContract.cPayWayMemo;
	    	        		printTable += "</td>";
	    	        	printTable += "</tr>";
	    	        	printTable += "<tr rowspan='3'>";
		    	        	printTable += "<td rowspan='3'>保函情况";
	    	        		printTable += "</td>";
		    	        	printTable += "<td>履约保函";
	    	        		printTable += "</td>";
	    	        		if(data.beforeContract.nIsHasPS == true){
	    	        			printTable += "<td>无";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>有";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>√";
		    	        		printTable += "</td>";
	    	        		}else{
	    	        			printTable += "<td>无";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>√";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>有";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>";
		    	        		printTable += "</td>";
	    	        		}
	    	        		printTable += "<td colspan='2'>是否银行标准格式";
	    	        		printTable += "</td>";
	    	        		if(data.beforeContract.nPSIsFormat == true){
	    	        			printTable += "<td>无";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>&nbsp;";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>有";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>√";
		    	        		printTable += "</td>";
	    	        		}else{
	    	        			printTable += "<td>无";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>√";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>有";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>";
		    	        		printTable += "</td>";
	    	        		}
	    	        	printTable += "</tr>";
	    	        	printTable += "<tr>";
		    	        	printTable += "<td>质量保函";
	    	        		printTable += "</td>";
	    	        		if(data.beforeContract.nIsHasQS == true){
	    	        			printTable += "<td>无";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>有";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>√";
		    	        		printTable += "</td>";
	    	        		}else{
	    	        			printTable += "<td>无";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>√";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>有";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>";
		    	        		printTable += "</td>";
	    	        		}
	    	        		printTable += "<td colspan='2'>是否银行标准格式";
	    	        		printTable += "</td>";
	    	        		if(data.beforeContract.nQSIsFormat == true){
	    	        			printTable += "<td>无";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>&nbsp;";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>有";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>√";
		    	        		printTable += "</td>";
	    	        		}else{
	    	        			printTable += "<td>无";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>√";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>有";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>";
		    	        		printTable += "</td>";
	    	        		}
	    	        	printTable += "</tr>";
	    	        	printTable += "<tr>";
		    	        	printTable += "<td>其他保函";
	    	        		printTable += "</td>";
	    	        		if(data.beforeContract.nIsHasOS == true){
	    	        			printTable += "<td>无";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>有";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>√";
		    	        		printTable += "</td>";
	    	        		}else{
	    	        			printTable += "<td>无";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>√";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>有";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>";
		    	        		printTable += "</td>";
	    	        		}
	    	        		printTable += "<td colspan='2'>是否银行标准格式";
	    	        		printTable += "</td>";
	    	        		if(data.beforeContract.nOSIsFormat == true){
	    	        			printTable += "<td>无";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>&nbsp;";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>有";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>√";
		    	        		printTable += "</td>";
	    	        		}else{
	    	        			printTable += "<td>无";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>√";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>有";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>";
		    	        		printTable += "</td>";
	    	        		}
	    	        	printTable += "</tr>";
	    	        	printTable += "<tr>";
		    	        	printTable += "<td rowspan='2'>资料要求";
	    	        		printTable += "</td>";
	    	        		printTable += "<td>送审资料";
	    	        		printTable += "</td>";
	    	        		if(data.beforeContract.nIsHasVerifyData == true){
	    	        			printTable += "<td>无";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>&nbsp;";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>有";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>√";
		    	        		printTable += "</td>";
	    	        		}else{
	    	        			printTable += "<td>无";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>√";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>有";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>";
		    	        		printTable += "</td>";
	    	        		}
	    	        		printTable += "<td colspan='6'>"+data.beforeContract.cVerifyDataMemo;
	    	        		printTable += "</td>";
	    	        	printTable += "</tr>";
	    	        	printTable += "<tr>";
	    	        		printTable += "<td>最终资料";
	    	        		printTable += "</td>";
	    	        		if(data.beforeContract.nIsHasFinnalData == true){
	    	        			printTable += "<td>无";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>&nbsp;";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>有";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>√";
		    	        		printTable += "</td>";
	    	        		}else{
	    	        			printTable += "<td>无";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>√";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>有";
		    	        		printTable += "</td>";
		    	        		printTable += "<td>";
		    	        		printTable += "</td>";
	    	        		}
	    	        		printTable += "<td colspan='6'>"+data.beforeContract.cFinnalDataMemo;
	    	        		printTable += "</td>";
	    	        	printTable += "</tr>";
	    	        	printTable += "<tr>";
		    	        	printTable += "<td>违约责任";
		    	        	printTable += "</td>";
		    	        	printTable += "<td colspan='11'>"+data.beforeContract.cLiabilityMemo;
		    	        	printTable += "</td>";
	    	        	printTable += "</tr>";
	    	        	var qtCount = data.qtzytk.length;
	    	        	printTable += "<tr >";
		    	        	printTable += "<td rowspan='"+qtCount+"'>其他注意条款";
		    	        	printTable += "</td>";
		    	        	for(var aa = 0;aa < qtCount;aa++){
		    	        		printTable += "<td>"+data.qtzytk[aa].nOrderNumber;
		    	        		printTable += "</td>";
		    	        		printTable += "<td colspan='10'>"+data.qtzytk[aa].cContent;
		    	        		printTable += "</td>";
		    	        		printTable += "</tr>";
		    	        	}
		    	       printTable += "<tr>";
			    	       printTable += "<td>售后服务条款";
			    	       printTable += "</td>";
			    	       printTable += "<td colspan='11'>"+data.beforeContract.cAfterSaleClauseMemo;
			    	       printTable += "</td>";
		    	       printTable += "</tr>";
		    	       printTable += "<tr>";
		    	       	   printTable += "<td>预排产申请";
		    	       	   printTable += "</td>";
		    	       	   printTable += "<td>排图";
		    	       	   printTable += "</td>";
		    	       	   if(data.beforeContract.nIsBeforeDesign == true){
		    	       		   printTable += "<td>√";
			    	       	   printTable += "</td>";
		    	       	   }else{
		    	       		   printTable += "<td>";
			    	       	   printTable += "</td>";
		    	       	   }
		    	       	   printTable += "<td>排产";
		    	       	   printTable += "</td>";
			    	       	if(data.beforeContract.nIsBeforeProduce == true){
			    	       		   printTable += "<td>√";
				    	       	   printTable += "</td>";
			    	       	}else{
			    	       		   printTable += "<td>";
				    	       	   printTable += "</td>";
			    	       	}
			    	       	printTable += "<td>原因";
			    	       	printTable += "</td>";
			    	       	printTable += "<td colspan='6'>"+data.beforeContract.cBeforeDPReason;
			    	       	printTable += "</td>";
		    	       printTable += "</tr>";
		    	       printTable += "<tr>";
	    	       		var httsCount = data.httstk.length
	    	       		printTable += "<td rowspan='"+httsCount+"'>合同特殊条款";
	    	       		printTable += "</td>";
	    	       		for(var kk = 0;kk<httsCount;kk++){
	    	       			printTable += "<td>"+data.httstk[kk].nOrderNumber;
		    	       		printTable += "</td>";
		    	       		printTable += "<td colspan='10'>"+data.httstk[kk].cContent;
		    	       		printTable += "</td>";
		    	       		printTable += "</tr>";
	    	       		}
	    	       		printTable += "<tr>";
	    	       			var wgjCount = data.beng.length;
		    	       		printTable += "<td rowspan='"+(wgjCount+1)+"'>外购件独家指定";
		    	       		printTable += "</td>";
		    	       		printTable += "<td>序号";
		    	       		printTable += "</td>";
		    	       		printTable += "<td colspan='2'>外购件名称";
		    	       		printTable += "</td>";
		    	       		printTable += "<td>数量";
		    	       		printTable += "</td>";
		    	       		printTable += "<td colspan='3'>外购件各厂家报价";
		    	       		printTable += "</td>";
		    	       		printTable += "<td colspan='4'>指定何家及原因";
		    	       		printTable += "</td>";
		    	       	printTable += "</tr>";
		    	       		for(var zz = 0;zz<wgjCount;zz++){
		    	       			printTable += "<tr>";
		    	       			printTable += "<td>"+data.beng[zz].nOrderNumber;
			    	       		printTable += "</td>";
			    	       		printTable += "<td colspan='2'>"+data.beng[zz].cWGName;
			    	       		printTable += "</td>";
			    	       		printTable += "<td>"+data.beng[zz].nCount;
			    	       		printTable += "</td>";
			    	       		printTable += "<td colspan='3'>"+data.beng[zz].cContent;
			    	       		printTable += "</td>";
			    	       		printTable += "<td colspan='4'>"+data.beng[zz].cReason;
			    	       		printTable += "</td>";
			    	       		printTable += "</tr>";
		    	       		}
		    	       	printTable += "<tr >";
			    	       	printTable += "<td rowspan='5'>需审核条款";
			    	       	printTable += "</td>";
			    	       	printTable += "<td>1";
			    	       	printTable += "</td>";
			    	       	printTable += "<td colspan='10'>片区人员签订的合同。";
			    	       	printTable += "</td>";
		    	       	printTable += "</tr>";
		    	       	printTable += "<tr >";
			    	       	printTable += "<td>2";
			    	       	printTable += "</td>";
			    	       	printTable += "<td colspan='10'>片区经理签订的合同；合同价格下浮超出片区经理权限；500万以下合同预排产；合同特殊条款；外购件独家指定。";
			    	       	printTable += "</td>";
		    	       	printTable += "</tr>";
		    	       	printTable += "<tr >";
			    	       	printTable += "<td>3";
			    	       	printTable += "</td>";
			    	       	printTable += "<td colspan='10'>100万以上合同；合同价格下浮超出处长权限；500万以上合同预排产；合同特殊条款；外购件独家指定。";
			    	       	printTable += "</td>";
		    	       	printTable += "</tr>";
		    	       	printTable += "<tr >";
			    	       	printTable += "<td>4";
			    	       	printTable += "</td>";
			    	       	printTable += "<td colspan='10'>100万以上合同。";
			    	       	printTable += "</td>";
		    	       	printTable += "</tr>";
		    	       	printTable += "<tr >";
			    	       	printTable += "<td>5";
			    	       	printTable += "</td>";
			    	       	printTable += "<td colspan='10'>合同价格下浮超出公司分管领导权限；外购件独家指定；公司级领导间审核意见有分歧的合同。";
			    	       	printTable += "</td>";
		    	       	printTable += "</tr>";
		    	       	printTable += "<tr>";
			    	       	printTable += "<td colspan='2'>1</br>片区经理意见( )";
			    	       	printTable += "</td>";
			    	       	printTable += "<td colspan='3'>2</br>分管处长意见( )";
			    	       	printTable += "</td>";
			    	       	printTable += "<td colspan='2'>3</br>公司分管领导意见( )";
			    	       	printTable += "</td>";
			    	       	printTable += "<td colspan='2'>4</br>法制办意见( )";
			    	       	printTable += "</td>";
			    	       	//printTable += "<td colspan='2'>4</br>财务总监意见( )";
			    	       	//printTable += "</td>";
			    	       	printTable += "<td colspan='3'>5</br>总经理意见( )";
			    	       	printTable += "</td>";
		    	       	printTable += "</tr>";
		    	       	
		    	       	printTable += "<tr height='80px'>";
		    	       		//printTable += data.nodes[nn].auditAdvice ;
		    	       		printTable += "<td colspan='2'>";
		    	       		if(data.nodes.length > 0){
		    	       			var auditAdvice = data.nodes[0].auditAdvice == undefined ? "" : data.nodes[0].auditAdvice;
		    	       			var createTime = data.nodes[0].createTime == undefined ? "" : new Date(data.nodes[0].createTime).toLocaleDateString();
		    	       			printTable += auditAdvice  + '</br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + data.nodes[0].auditor.name 
		    	       							+ '</br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + createTime ;
		    	       		}
			    	       	printTable += "</td>";
			    	       	printTable += "<td colspan='3'>";
			    	       	if(data.nodes.length > 1){
			    	       		var auditAdvice = data.nodes[1].auditAdvice == undefined ? "" : data.nodes[1].auditAdvice;
			    	       		var createTime = data.nodes[1].createTime == undefined ? "" : new Date(data.nodes[1].createTime).toLocaleDateString();
			    	       		printTable += auditAdvice  + '</br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + data.nodes[1].auditor.name 
			    	       						+ '</br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + createTime ;
		    	       		}
			    	       	printTable += "</td>";
			    	       	printTable += "<td colspan='2'>";
			    	       	if(data.nodes.length > 2){
			    	       		var auditAdvice = data.nodes[2].auditAdvice == undefined ? "" : data.nodes[2].auditAdvice;
			    	       		var createTime = data.nodes[2].createTime == undefined ? "" : new Date(data.nodes[2].createTime).toLocaleDateString();
			    	       		printTable += auditAdvice  + '</br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + data.nodes[2].auditor.name 
			    	       						+ '</br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + createTime ;
		    	       		}
			    	       	printTable += "</td>";
			    	       	
			    	       	if(data.beforeContract.nContractPrice <= 5000000){
			    	       		printTable += "<td colspan='2'>";
			    	       		printTable += "</td>";
				    	       	printTable += "<td colspan='3'>";
				    	       	if(data.nodes.length > 3){
				    	       		var auditAdvice = data.nodes[3].auditAdvice == undefined ? "" : data.nodes[3].auditAdvice;
				    	       		var createTime = data.nodes[3].createTime == undefined ? "" : new Date(data.nodes[3].createTime).toLocaleDateString();
				    	       		printTable += auditAdvice  + '</br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + data.nodes[3].auditor.name 
				    	       					+ '</br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + createTime ;
			    	       		}
				    	       	printTable += "</td>";
			    	       	}else{
			    	       		printTable += "<td colspan='2'>";
				    	       	if(data.nodes.length > 3){
				    	       		var auditAdvice = data.nodes[3].auditAdvice == undefined ? "" : data.nodes[3].auditAdvice;
				    	       		var createTime = data.nodes[3].createTime == undefined ? "" : new Date(data.nodes[3].createTime).toLocaleDateString();
				    	       		printTable += auditAdvice  + '</br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + data.nodes[3].auditor.name 
				    	       					+ '</br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + createTime ;
			    	       		}
				    	       	printTable += "</td>";
				    	       	printTable += "<td colspan='3'>";
				    	       	if(data.nodes.length > 4){
				    	       		var auditAdvice = data.nodes[4].auditAdvice == undefined ? "" : data.nodes[4].auditAdvice;
				    	       		var createTime = data.nodes[4].createTime == undefined ? "" : new Date(data.nodes[4].createTime).toLocaleDateString();
			    	       			printTable += auditAdvice  + '</br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + data.nodes[4].auditor.name 
			    	       						+ '</br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + createTime ;
			    	       		}
				    	       	printTable += "</td>";
			    	       	}
		    	       	printTable += "</tr>";
	    	        printTable+= "</table>";
	    	        printTable += "<div style='margin-left:30px;font-size:11px'>表格填写说明：</br>"
	    	       	printTable += "&nbsp;&nbsp;&nbsp;&nbsp;1、提交本审核表时应同时提交草拟合同和技术协议。</br>"
	    	       	printTable += "&nbsp;&nbsp;&nbsp;&nbsp;2、表格填写内容必须与草拟合同和协议一致。</br>"
	    	       	printTable += "&nbsp;&nbsp;&nbsp;&nbsp;3、表格中的可选项“√”，如需则在相应栏内打“√”，如无需则将“√”删除。</br>"
    	       		printTable += "&nbsp;&nbsp;&nbsp;&nbsp;4、表格内容仅供填写参考，请删除后填写。</br>"
	       			printTable += "&nbsp;&nbsp;&nbsp;&nbsp;5、本表格格式不允许私自调整，如果内容较多可添加行。</div>"
	    	        document.getElementById("printTab").innerHTML = printTable;
	    	        //jQuery("#printDiv").modal('show');
	    	        prn1_preview();
	    		}
	    	});
	   }
    	
    })
    function prn1_preview() {
    	CreateOneFormPage();
        LODOP.PREVIEW();
    };
    function CreateOneFormPage() {
        LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'));
        LODOP.SET_PRINT_PAGESIZE(1, 0, 0, "A4");
        /*LODOP.SET_PRINT_PAGESIZE(2, "0", "0", "A4");*/
        LODOP.ADD_PRINT_HTM(0,0 , "95%", "95%", document.getElementById("printTab").innerHTML);
        
        /*LODOP.ADD_PRINT_HTM("95%","40%","100%","100%","总页号：<span tdata='pageNO'>第##页</span>/<span tdata='pageCount'>共##页</span></font>");*/
       /*
        LODOP.ADD_PRINT_HTM("37%","40%","100%","100%","<font style='font-size:12px'; float:left; format='ChineseNum'><span tdata='pageNO'>第##页</span>/<span tdata='pageCount'>共##页</span></font>");
    	LODOP.SET_PRINT_STYLEA(0,"ItemType",1);*/
    	/*LODOP.ADD_PRINT_TEXT("37%","40%","100%","100%", "第#页/共&页");
        LODOP.SET_PRINT_STYLEA(2, "ItemType", 2);
        LODOP.SET_PRINT_STYLEA(2, "HOrient", 1);*/
    };

    //查询
    jQuery('#searchBtn').on('click',function(){
        serverData.key=jQuery('#search').val();
        serverTable.draw();
    })
    //撤销查询
    jQuery('#resetBtn').on("click",function()
    {
        jQuery('#search').val('');
    });
    
    //新增
    jQuery('#addBtn').on("click",function()
    {
    	window.location.href = window.rootPath + '/ui/beforecontract/add';
    });
    
    //修改
    jQuery('#editBtn').on("click",function()
    {
    	var selects=getSelect("#dataTable",1);
		   if(selects.length>1){
			   $.springLemonDialog({
			         content: '只能编辑一条记录',// 确认文本
			         clickButton: function (sender, modal, index) {// 按钮事件处理
			             $(this).closeDialog(modal);
			         }
			   }); 
		   }
		   else if(selects.length==0){
			   $.springLemonDialog({
			         content: '请选择要编辑的记录',// 确认文本
			         clickButton: function (sender, modal, index) {// 按钮事件处理
			             $(this).closeDialog(modal);
			         }
			   }); 
		   }else if(selects.length==1){
			    var auditState = selects[0].auditState;
				if (auditState == '审批中' || auditState == '已提交') {
					$.springLemonDialog({
						content : '审批中，不能编辑',// 确认文本
						clickButton : function(sender, modal, index) {// 按钮事件处理
							$(this).closeDialog(modal);
						}
					});
				} else if (auditState == '通过') {
					$.springLemonDialog({
						content : '已经通过审批，不能编辑',// 确认文本
						clickButton : function(sender, modal, index) {// 按钮事件处理
							$(this).closeDialog(modal);
						}
					});
				} else {
					var id=selects[0].id;
	    			var url=window.rootPath+'/ui/beforecontract/edit/'+ id;
	    			window.location.href = url;
				}
		   }
    });
    
    //删除
    jQuery('#delBtn').on("click",function()
    {
    	var selects=getSelect("#dataTable",1);
		   if(selects.length>1){
			   $.springLemonDialog({
			         content: '只能删除一条记录',// 确认文本
			         clickButton: function (sender, modal, index) {// 按钮事件处理
			             $(this).closeDialog(modal);
			         }
			   }); 
		   }
		   else if(selects.length==0){
			   $.springLemonDialog({
			         content: '请选择要删除的记录',// 确认文本
			         clickButton: function (sender, modal, index) {// 按钮事件处理
			             $(this).closeDialog(modal);
			         }
			   }); 
		   }else if(selects.length==1){
			    var auditState = selects[0].auditState;
				if (auditState == '审批中' || auditState == '已提交') {
					$.springLemonDialog({
						content : '审批中，不能删除',// 确认文本
						clickButton : function(sender, modal, index) {// 按钮事件处理
							$(this).closeDialog(modal);
						}
					});
				} else if (auditState == '通过') {
					$.springLemonDialog({
						content : '已经通过审批，不能删除',// 确认文本
						clickButton : function(sender, modal, index) {// 按钮事件处理
							$(this).closeDialog(modal);
						}
					});
				} else {
					var id=selects[0].id;
					$.springLemonDialog({
       		         content: '确认删除'+selects.length+'条记录？',// 确认文本
       		         clickButton: function (sender, modal, index) {// 按钮事件处理
       		        	 if (index == 0) {
       		        		 jQuery.ajax({
       		        			    url:encodeURI(window.rootPath + "/ui/beforecontract/delete?id="+id),
       		        	            cache:false,
       		        	            type :"get",
       		        	            dataType:"json",
       		        	            contentType:"application/json;charset=utf-8",//解决返回数据中的中文乱码问题
       		        	            success:function(data){
       		        	            	serverData.key=jQuery('#search').val();
       		        	            	serverTable.draw();
       		        	            	//tableName.draw(false); 
       		        	            }
       		        	        });	
       		        	 }
       		             $(this).closeDialog(modal);
       		         }
       		       });
					//var url=window.rootPath+'/ui/beforecontract';
	    			//window.location.href = url;
				}
		   }
    });
    
 // 发起审批
    jQuery("#submitBtn").on('click',function(){
   	 var selects=getSelect("#dataTable",1);
   	 if(selects.length>1){
   		   $.springLemonDialog({
   		         content: '一次只能对一条记录发起审批',// 确认文本
   		         clickButton: function (sender, modal, index) {// 按钮事件处理
   		             $(this).closeDialog(modal);
   		         }
   		   }); 
   	   }
   	   else if(selects.length==0){
   		   $.springLemonDialog({
   		         content: '请选择要发起审批的记录',// 确认文本
   		         clickButton: function (sender, modal, index) {// 按钮事件处理
   		             $(this).closeDialog(modal);
   		         }
   		   }); 
   	   }else if(selects.length==1){
   		  if(selects[0].auditState=='通过'){
   			$.springLemonDialog({
  					content : selects[0].cContractCode+'已经审批通过',// 确认文本
  					clickButton : function(sender, modal, index) {// 按钮事件处理
  						$(this).closeDialog(modal);
  					}
            		});
   				return;
   			}
   		  if(selects[0].auditState=='已提交'  || selects[0].auditState=='审批中' ){
   			$.springLemonDialog({
					content : selects[0].cContractCode+'已经提交审批',// 确认文本
					clickButton : function(sender, modal, index) {// 按钮事件处理
						$(this).closeDialog(modal);
					}
        		});
   				return;
   			}
   		 var id=selects[0].id;
   		 var url=window.rootPath+'/ui/beforecontract/audit/'+ id;
   		 window.location = url;
   	   }
   });
    
    jQuery("#cancelBtn").on('click',function() {
        var selects = getSelect("#dataTable", 1);
        if (selects.length > 1) {
            $.springLemonDialog({
                content: '一次只能对一条记录撤销审批',// 确认文本
                clickButton: function (sender, modal, index) {// 按钮事件处理
                    $(this).closeDialog(modal);
                }
            });
        }
        else if (selects.length == 0) {
            $.springLemonDialog({
                content: '请选择要撤销审批的记录',// 确认文本
                clickButton: function (sender, modal, index) {// 按钮事件处理
                    $(this).closeDialog(modal);
                }
            });
        } else if (selects.length == 1) {
            if (selects[0].auditState != '已提交') {
            	$.springLemonDialog({
                    content: selects[0].cContractCode + '已不可撤销！\n只有“已提交”状态可撤销',// 确认文本
                    clickButton: function (sender, modal, index) {// 按钮事件处理
                        $(this).closeDialog(modal);
                    }
                });
                return;
            }

            var id = selects[0].id;

            jQuery.springLemonDialog({
                content: '确认撤销合同审批：' + selects[0].cContractCode + '？',// 确认文本
                clickButton: function (sender, modal, index) {
                    if (index == 1) {
                    	 jQuery(this).closeDialog(modal);
                        return;
                    }
                    var url = window.rootPath + '/ui/task/cancel/beforecontract/' + id;
                    jQuery.post(encodeURI(url), null, function (data) {
                        if (data.code == 0) {
                        	jQuery(this).closeDialog(modal);
                            window.location = window.rootPath + "/ui/beforecontract/";
                        }
                    });
                    jQuery(this).closeDialog(modal);
                }
            });
        }//end of if
    });
    
    //查看审批
    jQuery('#viewAuBtn').on('click', function () {
   		var selects=getSelect("#dataTable",1);
   		if(selects.length==0){
    		   $.springLemonDialog({
    		         content: '请选择要查看的记录',// 确认文本
    		         clickButton: function (sender, modal, index) {// 按钮事件处理
    		             $(this).closeDialog(modal);
    		         }
    		   }); 
   		}else if(selects.length>1){
    		   $.springLemonDialog({
    		         content: '一次只能查看一条记录的审批',// 确认文本
    		         clickButton: function (sender, modal, index) {// 按钮事件处理
    		             $(this).closeDialog(modal);
    		         }
    		   }); 
    	}else{
    		if(selects[0].auditState=='未提交'){
    			$.springLemonDialog({
   		         content: selects[0].cContractCode+'还没有提交审批',// 确认文本
   		         clickButton: function (sender, modal, index) {// 按钮事件处理
   		             $(this).closeDialog(modal);
   		         }
    			}); 
    	   		return;
    	   	}
    		var id=selects[0].id;
    		var url=window.rootPath+'/ui/task/audit-nodes/beforecontract/'+id;
    		//var url=window.rootPath+'/ui/task/audit-nodes/exdeBeforeContract/'+id;
       		jQuery.get(encodeURI(url),null,function(html){
       			jQuery('#modal-audit-nodes-content').html(html);
       			jQuery('#modal-audit-nodes').modal("show");
       		});
    	}
   	});	 

    
    //查看详情
    jQuery('#checkbtn').on('click',function(){
    	 var selects=getSelect("#dataTable",1);
    	 if(selects.length>1){
   		   $.springLemonDialog({
   		         content: '一次只能查看一条记录',// 确认文本
   		         clickButton: function (sender, modal, index) {// 按钮事件处理
   		             $(this).closeDialog(modal);
   		         }
   		   }); 
   	   }
   	   else if(selects.length==0){
   		   $.springLemonDialog({
   		         content: '请选择要查看的记录',// 确认文本
   		         clickButton: function (sender, modal, index) {// 按钮事件处理
   		             $(this).closeDialog(modal);
   		         }
   		   }); 
   	   }else if(selects.length==1){
   		var id=selects[0].id;
		var url=window.rootPath+'/ui/beforecontract/check/'+ id;
		window.location.href = url;
   		
   	   }
    });
    
    
    jQuery(document).ready(function () {
        serverTable = jQuery('#dataTable').DataTable({
            "serverSide" : true,
            "ordering" : false,
            "ajax" : {
                "dataType" : "json",
                "type" : "post",
                "cache" : false,
                "url" : window.rootPath + '/ui/beforecontract/getpage',
                "data" : function(d) {
                    return $.extend({}, d,
                            serverData);
                }
            },
            "columns" : [{
                            data : null,
                            defaultContent : ""// 排序   1
                        },
                        {
            	            data: null,
            	            defaultContent: "",
            	            render: function (data, type, full, meta) {
            	            	var id=data.id
            	            	var operate ='<input type="checkbox" class="checkchildContract">';
            	            	return operate;
            	            }   
                        },
                        {
                            data : 'cContractCode'//合同号,
        		                ,render:function(data,type,full,meta){
        		                	if(data == null || data == undefined || data == ""){
        								return data;
        							}else{
        								return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
        							}
        						}
                        },
                        {
                          	data: 'auditState',
                            render: function (data, type, full, meta) {
                             	var dOut;
                             	 if(data=='审批中'){
                             		dOut = '<td class="center" ><span class="badge label-pill label-primary">审批中</span></td>';
                             	}
                             	else if(data=='驳回'){
                             		dOut = '<td class="center" ><span class="badge label-pill label-danger">驳回</span></td>';
                             	}
                             	else if(data=='通过'){
                             		dOut = '<td class="center" ><span class="badge label-pill label-success">通过</span></td>';
                             	}
                             	else  if(data=='未提交'){
                             		dOut = '<td class="center" ><span class="badge label-pill label-default">未提交</span></td>';
                             	}
                            	else  if(data=='已提交'){
                             		dOut = '<td class="center" ><span class="badge label-pill label-warning">已提交</span></td>';
                             	}
             	            	return dOut;
                             }
                        },
                        {
                            data : 'cCounterSignState'//会签状态
                        },
                        {
                            data : 'cOrderUnitName'//订货单位,
        		                ,render:function(data,type,full,meta){
        		                	if(data == null || data == undefined || data == ""){
        								return data;
        							}else{
        								return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
        							}
        						}
                        },
                        {
                            data : 'cDutyPersonName'//合同责任人
                        },
                        {
                            data : 'nContractPrice'//合同总价
                        },
                        {
                            data : 'cProjectName'//项目名称,
        		                ,render:function(data,type,full,meta){
        		                	if(data == null || data == undefined || data == ""){
        								return data;
        							}else{
        								return (data.length > 6) ? '<font title="'+data+'">'+data.substring(0,6)+'...'+'</font>' : data;
        							}
        						}
                        },
                        {
                            data : 'dPlanSignDate',//预计签订日期
                            render: function (data, type, full, meta) {
                                if (data)
                                    return moment(data).format('YYYY/MM/DD HH:mm');
                                else
                                    return '';
                            }
                        },
                        {
                            data : 'cDeliveryMemo'//交货期
                            	,
        		                render:function(data,type,full,meta){
        		                	if(data == null || data == undefined || data == ""){
        								return data;
        							}else{
        								return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
        							}
        						}
                        },
                        {
                            data : 'cQualityMemo'//质保期
                            	,
        		                render:function(data,type,full,meta){
        		                	if(data == null || data == undefined || data == ""){
        								return data;
        							}else{
        								return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
        							}
        						}
                        },
                        {
                            data : 'cPayWayMemo'//付款方式
                            	,
        		                render:function(data,type,full,meta){
        		                	if(data == null || data == undefined || data == ""){
        								return data;
        							}else{
        								return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
        							}
        						}
                        },
                        {
                            data : 'cLiabilityMemo'//违约责任
                            	,
        		                render:function(data,type,full,meta){
        		                	if(data == null || data == undefined || data == ""){
        								return data;
        							}else{
        								return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
        							}
        						}
                        },
                        {
                            data : 'cAfterSaleClauseMemo',//售后服务条款,
        		                render:function(data,type,full,meta){
        		                	if(data == null || data == undefined || data == ""){
        								return data;
        							}else{
        								return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
        							}
        						}
                        },
                        {
                        	data : 'user.name'
                        },
                        {
                            data: 'attachNumber',//附件个数
                            render: function (data, type, full, meta) {
                            	var dOut;
                            	if(data==null){
                            		dOut='<td class="center" ><span class="badge label-pill label-primary">'+0+'</span></td>'
                            	}else{
                            		dOut='<td class="center" ><span class="badge label-pill label-primary">'+data+'</span></td>'
                            	}
                            	return dOut;
                            }
                            
                        }],
            "drawCallback": function (oSettings) {
                var k = 0;
                var total = oSettings.aiDisplay.length + oSettings._iDisplayStart;

                for (var i = oSettings._iDisplayStart, iLen = total; i < iLen; i++) {
                    $('td:eq(0)', oSettings.aoData[oSettings.aiDisplay[k]].nTr).text(i + 1);
                    k++;
                }
            }
        });
    });
})();